package com.itheima.controller.admin;

import com.itheima.common.result.Result;
import com.itheima.vo.BaseInfoVo;
import com.itheima.dto.UserLoginDTO;
import com.itheima.service.IndexService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("index")
@Slf4j
public class IndexController {
    @Autowired
    IndexService indexService;

    @PostMapping("login")
    public Result login(@RequestBody UserLoginDTO dto){
        log.info("开始登录");
        return indexService.login(dto);
    }

    @GetMapping("getConfig")
    public Result sysConfig(){
        return indexService.getConfig();
    }

    @PostMapping ("profile")
    public Result profile(){
        return indexService.profile();
    }

    /**
     * 主页统计信息
     * @return
     */
    @GetMapping("baseInfo")
    public Result<BaseInfoVo> baseInfo(){

        return Result.success(indexService.baseInfo());
    }

}
